[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
fmod() Calculate Floating-Point Remainder
#include <math.h> Required for declarations only
double fmod(x,y);
double x; Floating-point dividend
double y; Floating-point divisor
fmod() returns the remainder of 'x'/'y'. The remainder (r) will have
the same sign as 'x'; the absolute value of (r) will be less than the
absolute value of 'y'; and the following equation will be true:
(x == i * y + r)
where (i) is a signed integer and (r) is the value returned by
fmod().
Returns: Remainder of 'x'/'y'. If 'y' is 0.0 then 0.0 is
returned.
-------------------------------- Example ---------------------------------
The following statements calculate the floating point remainders of
-15.0 / 4.0, 6.1 / -2.5 and 5.5 / 0.0:
#include <math.h> /* Required for function definition only */
main()
{
double x, y, z;
x = fmod(-15.0, 4.0); /* x = -3.0 */
y = fmod(6.1, -2.5); /* y = 1.1 */
z = fmod(5.5, 0.0); /* z = 0.0 */
}
See Also:
ceil()
fabs()
floor()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson